/*
 * @Description:
 * @Author: py
 * @Date: 2024-12-12
 */
export function useDicts() {
    const oStationType = {
        1: '自营',
        2: '合作',
    }
    const oBusinessType = {
        1: '小桔充电',
    }
    const oRateType = {
        1: '固定比例',
        2: '阶梯式比例',
    }
    const dicts = {
        oStationType,
        oBusinessType,
        oRateType,
    }

    const getDictLabel = (mapKey: string, dicKey: number | string) => {
        if (mapKey in dicts) {
            return dicts[mapKey][dicKey]
        }
        else {
            return ''
        }
    }

    const getDictOptions = (mapKey: string) => {
        if (mapKey in dicts) {
            const targetMap = dicts[mapKey]
            const dictOptions = Object.entries(targetMap).map(([key, val]: [string, string]) => ({
                label: val,
                value: key,
            }))
            return ref(dictOptions)
        }
        else {
            return ref([])
        }
    }

    return { getDictLabel, getDictOptions }
}
